'''
Created on 26.11.2009

@author: guest
'''
from google.appengine.ext import webapp, db
from ru.simpleprojecttool.utils import utils
from ru.simpleprojecttool.db.model import Task, Comment
from google.appengine.api import users

class SaveComment(webapp.RequestHandler):
    task = Task
    def execute(self):
        text = self.request.get('commentText')
        if text:
            comment = Comment(creator = users.get_current_user(), 
                              text = text, 
                              task = self.task)
            comment.put()
        
        self.redirect('/editTask?taskId=%s' % str(self.task.key()))
    def post(self):
        self.task = db.get(db.Key(self.request.get('taskId')))
        utils.checkCanEditTask(self.task, self)